<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var smallestEqual = function (nums) {
      const n = nums.length
      for (let i = 0; i < n; i++) {
        if (i % 10 === nums[i]) {
          return i
        }
      }
      return -1
    };
    console.log(smallestEqual(nums = [4, 3, 2, 1]))
  </script>
</body>

</html>